<?php use_helper('jQuery')?>

<div id="main_header" class="ui-widget-header ui-corner-all">
    <h3>Datos del Bloque de Destacados: "<?php echo $element->getTitle() ?>""</h3>
</div>
<div id="main_content" class="ui-widget ui-widget-content ui-corner-all">
    <table>
        <?php if($sf_user->hasCredential('Editar elemento')): ?>
            <tfoot>
                <tr>
                    <td colspan="2">
                         <?php echo jq_link_to_remote(
                                '<span class="ui-button-icon-primary ui-icon ui-icon-pencil"></span>
                                <span class="ui-button-text">Editar</span>',
                            array(
                                'update' => 'main',
                                'url' => url_for('element_edit',$element),
                                'before' => 'clearView();showLoaderMain();',
                                'complete' => 'hideLoader();',
                                'script' => true
                            ), array(
                                'class' => 'ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary',
                                'title' => 'Editar'
                            )) ?>
                    </td>
                </tr>
            </tfoot>
        <?php endif; ?>
        <tbody>
            <tr>
                <th>Sección:</th>
                <td>
                    <?php echo jq_link_to_remote(
                            $element->getSection(),
                        array(
                            'update' => 'main',
                            'url' => url_for('section_show',$element->getSection()),
                            'before' => 'clearView();showLoaderMain();',
                            'complete' => 'hideLoader();',
                            'script' => true
                        )) ?>
                </td>
            </tr>
            <tr>
                <th>Posición:</th>
                <td><?php echo $element->getPosition()?></td>
            </tr>
            <tr>
                <th>Utiliza viñetas:</th>
                <td>
                    <?php if ($element->getMenu()->getUsesBullet()): ?>
                        Si
                    <?php else: ?>
                        No
                    <?php endif; ?>
                </td>
            </tr>
            <?php if ($element->getFeaturesBlock()->getUsesBullet()): ?>
                <tr>
                    <th>Viñeta:</th>
                    <td><img alt="<?php echo $element->getFeaturesBlock()->getBullet() ?>"
                         src="<?php echo '/uploads/portal_'.$element->getSection()->getPortalId().'/images/'.$element->getFeaturesBlock()->getBullet() ?>"/>
                    </td>
                </tr>
                <tr>
                    <th>Viñeta para nuevos:</th>
                    <td><img alt="<?php echo $element->getFeaturesBlock()->getBulletNew() ?>"
                         src="<?php echo '/uploads/portal_'.$element->getSection()->getPortalId().'/images/'.$element->getFeaturesBlock()->getBulletNew() ?>"/>
                    </td>
                </tr>
            <?php endif;?>
            <tr>
                <th colspan="2">Numero de destacados: <?php echo $element->getFeaturesBlock()->getFeatures()->count()?></th>
            </tr>
            <tr>
                <td colspan="2">
                    <table>
                        <?php foreach ($element->getFeaturesBlock()->getFeatures() as $i=>$feature):?>
                            <tr class="<?php echo ($i%2 ? 'odd' : 'even')?>">
                                <th>Contenido:</th>
                                <td>
                                    <?php echo jq_link_to_remote(
                                            $feature->getContent(),
                                        array(
                                            'update' => 'main',
                                            'url' => url_for('content_show',$feature->getContent()),
                                            'before' => '$("#main").empty();showLoaderMain();',
                                            'complete' => 'hideLoader();',
                                            'script' => true
                                        )) ?>
                                </td>
                            </tr>
                        <?php endforeach;?>
                    </table>
                </td>
            </tr>
            <tr>
                <th>Publicado:</th>
                <td>
                    <?php if ($element->getPublished() == true): ?>
                        <img alt="Sí" src="/images/util/check.png">
                    <?php else: ?>
                        <img alt="No" src="/images/util/cross.png">
                    <?php endif; ?>
                </td>
            </tr>
            <tr>
                <th>Fecha de creación:</th>
                <td><?php echo $element->getDateTimeObject('created_at')->format('d/m/Y - g:i a') ?></td>
            </tr>
            <tr>
                <th><label>Ultima modificación:</label></th>
                <td><?php echo $element->getDateTimeObject('updated_at')->format('d/m/Y - g:i a') ?></td>
            </tr>
        </tbody>
    </table>
</div>